from  django.template import RequestContext
from django.shortcuts import render_to_response
from blog.models import *

def index(request):
	posts = Post.objects.all()
	categorys = Category.objects.all()
	websites = Favourite_website.objects.all()
	pages = Page.objects.all()
	return render_to_response('index.html', {'posts':posts,'cat':categorys,'webs':websites,'pages':pages},RequestContext(request))
	

def category(request,category_id):
	posts = Post.objects.filter(category=category_id)
	categorys = Category.objects.all()
	websites = Favourite_website.objects.all()
	pages = Page.objects.all()
	return render_to_response('index.html', {'posts':posts,'cat':categorys,'webs':websites,'pages':pages},RequestContext(request))
	
def post(request,post_id):
	posts = Post.objects.filter(id=post_id)
	categorys = Category.objects.all()
	websites = Favourite_website.objects.all()
	pages = Page.objects.all()
	return render_to_response('index.html', {'posts':posts,'cat':categorys,'webs':websites,'pages':pages},RequestContext(request))
	
def page(request,page_id):
	page = Page.objects.get(id=page_id)
	pages = Page.objects.all()
	categorys = Category.objects.all()
	websites = Favourite_website.objects.all()
	return render_to_response('page.html', {'page':page,'pages':pages,'cat':categorys,'webs':websites},RequestContext(request))